package org.iteam.xlz.manager.action.user;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.iteam.web.struts.action.AbstractModuleAction;
import org.iteam.web.struts.action.RestAction;
import org.iteam.web.struts.model.Model;
import org.iteam.xlz.core.entity.log.LogAccount;
import org.iteam.xlz.core.service.user.DollarService;

@SuppressWarnings("unchecked")
@Results({@Result(name="INDEX",type="freemarker",location="/WEB-INF/content/user/dollar-index.html"),
		 @Result(name="EDIT",type="freemarker",location="/WEB-INF/content/user/dollar-give.html")})
public class DollarAction extends AbstractModuleAction<LogAccount> implements RestAction{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 7661069417346983853L;
	private final String PATH="/user/dollar";
	@Override
	public LogAccount getModel() {
		if(null==model){
			model=new LogAccount();
		}
		return model;
	}

	@Override
	@Action(PATH+"/index")
	public String index() throws Exception {
		return INDEX;
	}

	@Override
	@Action(PATH+"/query")
	public String query() {
		try{
			map.put("total",DollarService.getInstance().counts(model));
			map.put("rows",DollarService.getInstance().query(model,page,rows));
		}catch(Exception e){
			e.printStackTrace();
		}
		return MAP;
	}

	@Override
	public String show() {
		return null;
	}

	@Override
	public String create() {
		return null;
	}

	@Override
	@Action(PATH+"/create")
	public String update() {
		map.put("state",DollarService.getInstance().update(model));
		return MAP;
	}

	@Override
	public String delete() {
		return null;
	}

	@Override
	public String destroy() {
		return null;
	}

	@Override
	@Action(PATH+"/new")
	public String edit() throws Exception {
		return EDIT;
	}

	@Override
	
	public String editNew() throws Exception {
		return null;
	}
}
